//
//  LineItemController.m
//  NtoccShipper
//
//  Created by 张天兴 on 2023/8/21.
//  Copyright © 2023 zhuchongjin. All rights reserved.
//

#import "LineItemController.h"
#import "LineItemCell.h"
#import "SendGoodsVC.h"
#import "SendLinesNameController.h"

@interface LineItemController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic, strong) UILabel *warningLabel;
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSArray *dataArr;

@end

@implementation LineItemController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setTitleName:CJLString(@"选择发布货源类型")];
    [self setBackLeftButton:@""];
    self.dataArr = @[@"发布大厅货源单",@"发布线路项目单"];
    [self.tableView registerNib:[UINib nibWithNibName:@"LineItemCell" bundle:nil] forCellReuseIdentifier:@"LineItemCell"];
    [self subViewLayout];
}
- (void)subViewLayout{
    [self.view addSubview:self.warningLabel];
    [self.view addSubview:_tableView];
}
- (UILabel *)warningLabel{
    if(_warningLabel == nil){
        self.warningLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, kTopHeight + 10, SCREEN_WIDTH - 20, 40)];
        self.warningLabel.text = @"提示：发布的线路项目不会出现在货源大厅，此类型的订单只可通过二维码方式承接";
        self.warningLabel.textColor = [UIColor cjMainColor];
        self.warningLabel.numberOfLines = 0;
        self.warningLabel.font = [UIFont systemFontOfSize:13];
    }
    return _warningLabel;
}
- (UITableView *)tableView
{
    if (!_tableView) {
        _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.frame = CGRectMake(0, CGRectGetMaxY(self.warningLabel.frame), SCREEN_WIDTH, 100);
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        _tableView.scrollEnabled = NO;
    }
    
    return _tableView;
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 2;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    LineItemCell *cell = [tableView dequeueReusableCellWithIdentifier:@"LineItemCell" forIndexPath:indexPath];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.nameLabel.text = self.dataArr[indexPath.row];
    return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 50;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 0) {
        SendGoodsVC *vc = [SendGoodsVC new];
        [self pushVc:vc];
    }else{
        SendLinesNameController *lineVC = [[SendLinesNameController alloc] init];
        [self pushVc:lineVC];
    }
}

@end
